package com.framework.disconf.service.impl;

import com.framework.disconf.service.IUserService;
import com.framework.disconf.entity.User;
import com.framework.disconf.dao.master.IUserDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Date;

@Service
public class UserServiceImpl implements IUserService{

    private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    IUserDao userDao;

    /**
     * 创建
     * @param user
     */
    @Override
    public void create(User user) {
        Date now = new Date();
        userDao.insert(user);
    }

    /**
     * 修改
     * @param user
     */
    @Override
    public void modifyById(User user) {
        userDao.updateById(user);
    }

    /**
     * 根据主键删除
     * @param id
     */
    @Override
    public void deleteById(Long id) {
        int count = userDao.deleteById(id);
    }

    /**
     * 根据主键获取
     * @param id
     * @return
     */
    @Override
    public User getUserById(Long id) {
        User result = null;
        if(null == id){
            return result;
        }
        result = userDao.getById(id);
        return result;
    }

    @Override
    public void scheduleUserTask() {
        System.out.println("执行动态定时任务: " + LocalDateTime.now().toLocalTime());
    }

}